import {useRef, forwardRef} from 'react'; // 导入useRef和forwardRef
import {View, Button, TextInput} from 'react-native';

export default function App() {
  const ref = useRef<TextInput>(null);
  return (
    <View>
      <Son ref={ref} />
      <Button
        title="点击1"
        onPress={() => {
          ref.current?.focus();
        }}
      />
    </View>
  );
}

export const Son = forwardRef<TextInput>((props, ref) => {
  return (
    <View>
      <TextInput ref={ref}>123</TextInput>
    </View>
  );
});
